package com.lzj.common.translation.impl;

import cn.hutool.core.util.ObjectUtil;
import com.lzj.common.annotation.TranslationType;
import com.lzj.common.constant.Constants;
import com.lzj.common.constant.TransConstant;
import com.lzj.common.core.service.OssService;
import com.lzj.common.translation.TranslationInterface;
import com.lzj.common.utils.StringUtils;
import lombok.AllArgsConstructor;
import org.springframework.stereotype.Component;

/**
 * OSS翻译实现
 *
 * @author 贱贱
 */
@Component
@AllArgsConstructor
@TranslationType(type = TransConstant.OSS_ID_TO_URL)
public class OssUrlTranslationImpl implements TranslationInterface<String> {

    private final OssService ossService;

    @Override
    public String translation(Object key, String other) {
        String ossUrl = Constants.OSS_NOT_EXIST;
        if (ObjectUtil.isNotNull(key)) {
            ossUrl  = ossService.selectUrlByIds(key.toString());
        }
        return ossUrl;
    }
}
